package edu.scsu.csci.converter;

import edu.scsu.csci.IConverter;


/**
 *
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see
 * @viz.diagram SimpleCharacterConverter.tpx
 */
final public class SimpleCharacterConverter implements IConverter<Character> {
	
	/**
	 * @see edu.scsu.csci.IConverter#convert(java.lang.String, java.lang.Class)
	 */
	public Character convert(String value, Class<?> type)	throws ConversionException {
		try	{
			if (value == null || value.equals("")) {
				return null;
			}
			if (value.length() < 1) {
				throw new ConversionException("parameter passed is empty");
			}
			return Character.valueOf(value.charAt(0));
		}catch(Exception e){
			throw new ConversionException("Illegal value.");
		}
	}
	
}
